<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SSH终端客户端</title>
  <style>
    body, html {
      margin: 0;
      padding: 0;
      height: 100%;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
      overflow: hidden;
    }
    #root {
      height: 100%;
    }
  </style>
</head>
<body>
  <div id="root"></div>
  <script>
    // 为渲染进程提供IPC通信接口
    window.electron = {
      ipcRenderer: {
        send: (channel, data) => {
          window.postMessage({ type: 'ipc-send', channel, data }, '*');
        },
        on: (channel, listener) => {
          const wrappedListener = (event) => {
            if (event.data && event.data.type === 'ipc-message' && event.data.channel === channel) {
              listener(event, event.data.data);
            }
          };
          window.addEventListener('message', wrappedListener);
          return wrappedListener;
        },
        removeListener: (channel, listener) => {
          window.removeEventListener('message', listener);
        }
      }
    };
    
    // 转发IPC消息
    window.addEventListener('message', (event) => {
      if (event.data && event.data.type === 'ipc-send') {
        const { channel, data } = event.data;
        // 这里会被Electron的preload脚本拦截并处理
        console.log('IPC发送:', channel, data);
      }
    });
  </script>
  <script type="module" src="/src/renderer/index.jsx"></script>
</body>
</html>